home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / util / Mac F2C 1.3.sit / Mac F2C 1.3 / Mac F2C Libraries / libI77 Sources / sue.c < prev    next >
C/C++ Source or Header  |  1995-09-09  |  2KB  |  89 lines

  1. #include "f2c.h"
  2. #include "fio.h"
  3. extern uiolen f__reclen;
  4. long f__recloc;
  5.  
  6. #ifdef KR_headers
  7. c_sue(a) cilist *a;
  8. #else
  9. c_sue(cilist *a)
  10. #endif
  11. {
  12.     if(a->ciunit >= MXUNIT || a->ciunit < 0)
  13.         err(a->cierr,101,"startio");
  14.     f__external=f__sequential=1;
  15.     f__formatted=0;
  16.     f__curunit = &f__units[a->ciunit];
  17.     f__elist=a;
  18.     if(f__curunit->ufd==NULL && fk_open(SEQ,UNF,a->ciunit))
  19.         err(a->cierr,114,"sue");
  20.     f__cf=f__curunit->ufd;
  21.     if(f__curunit->ufmt) err(a->cierr,103,"sue")
  22.     if(!f__curunit->useek) err(a->cierr,103,"sue")
  23.     return(0);
  24. }
  25. #ifdef KR_headers
  26. integer s_rsue(a) cilist *a;
  27. #else
  28. integer s_rsue(cilist *a)
  29. #endif
  30. {
  31.     int n;
  32.     if(!f__init) f_init();
  33.     f__reading=1;
  34.     if(n=c_sue(a)) return(n);
  35.     f__recpos=0;
  36.     if(f__curunit->uwrt && f__nowreading(f__curunit))
  37.         err(a->cierr, errno, "read start");
  38.     if(fread((char *)&f__reclen,sizeof(uiolen),1,f__cf)
  39.         != 1)
  40.     {    if(feof(f__cf))
  41.         {    f__curunit->uend = 1;
  42.             err(a->ciend, EOF, "start");
  43.         }
  44.         clearerr(f__cf);
  45.         err(a->cierr, errno, "start");
  46.     }
  47.     return(0);
  48. }
  49. #ifdef KR_headers
  50. integer s_wsue(a) cilist *a;
  51. #else
  52. integer s_wsue(cilist *a)
  53. #endif
  54. {
  55.     int n;
  56.     if(!f__init) f_init();
  57.     if(n=c_sue(a)) return(n);
  58.     f__reading=0;
  59.     f__reclen=0;
  60.     if(f__curunit->uwrt != 1 && f__nowwriting(f__curunit))
  61.         err(a->cierr, errno, "write start");
  62.     f__recloc=ftell(f__cf);
  63. #if defined(CW_F2C) || defined(MPW_CW_F2C)
  64.     /* Do a dummy write, can't seek past EOF */
  65.     (void) fwrite((char *)&f__reclen,sizeof(uiolen),1,f__cf);
  66. #else
  67.     (void) fseek(f__cf,(long)sizeof(uiolen),SEEK_CUR);
  68. #endif
  69.     return(0);
  70. }
  71. integer e_wsue(Void)
  72. {    long loc;
  73.     fwrite((char *)&f__reclen,sizeof(uiolen),1,f__cf);
  74. #ifdef ALWAYS_FLUSH
  75.     if (fflush(f__cf))
  76.         err(f__elist->cierr, errno, "write end");
  77. #endif
  78.     loc=ftell(f__cf);
  79.     fseek(f__cf,f__recloc,SEEK_SET);
  80.     fwrite((char *)&f__reclen,sizeof(uiolen),1,f__cf);
  81.     fseek(f__cf,loc,SEEK_SET);
  82.     return(0);
  83. }
  84. integer e_rsue(Void)
  85. {
  86.     (void) fseek(f__cf,(long)(f__reclen-f__recpos+sizeof(uiolen)),SEEK_CUR);
  87.     return(0);
  88. }
  89.